//
//  NSString+OMTImagePicker.m
//  OMTImagePicker
//
//  Created by 刘绍湫 on 2018/2/11.
//

#import "NSString+OMTImagePicker.h"

@implementation NSString(OMTImagePicker)

- (NSString *)picker_replacePatternBy:(id) obj, ... NS_REQUIRES_NIL_TERMINATION{
    NSString *rtlStr = [NSMutableString stringWithString:self];
    va_list params;
    id argument;
    int i = 0;
    if (obj) {
        va_start(params, obj);
        NSString *targetStr = [NSString stringWithFormat:@"${%d}", ++i];
        rtlStr = [rtlStr stringByReplacingOccurrencesOfString:targetStr withString:[NSString stringWithFormat:@"%@", obj]];
        while ((argument = va_arg(params, id))) {
            targetStr = [NSString stringWithFormat:@"${%d}", ++i];
            rtlStr = [rtlStr stringByReplacingOccurrencesOfString:targetStr withString:[NSString stringWithFormat:@"%@", argument]];
        }
        
        va_end(params);
    }
    return rtlStr;
}

@end
